Hex Edit
In the beginning I created simple macros by recording my keystrokes and mouse
movements. But as I learned more and more and created more powerful macros I
began to realize the shortcomings in timing and lack of capability so I learned
the more advanced programming capabilities in ME and started making very
powerful macros which did more of the processes invisibly in variables.
A lot of this all happens behind the scenes invisible to the user and one will eventually need tools to lift the veil. In ME there are debug tools that will allow one to see the variables as they are being manipulated but what about the data? For that one needs a good hex editor. I use UltraEdit but there are many free alternatives.
What is Hex?
Well all this data we are working with is binary made of ones and zeros,
right? Well take 8 bits and you make a byte which gives 256 (2^8)
possibilities. This is base 16 instead of the base 10 you and I are
comfortable with. This byte is what's used in computers to store stuff
like text and each byte represents a letter. For instance the letter "a"
is 01100001. This is a pain to write but if we tried to use the base 10
system we get 97. Problem is when you get higher you need 3 digits decimal
(base 10) representation so IBM extended the normal number set to include
"a" thru "f" for a total of 16 characters. IE 0 thru F. That's base-16! "a" is 61 and "k" is 6B
for instance.
Why do we care? Because there are characters we can't see in something
like notepad that can effect our macros. I once was trying to copy a bunch
addresses for a mailer from Outlook and every 10 or so lines I would get
garbage. The problem was that Outlook allows users to put carriage returns
in the street address to separate a suite number for instance. Well my
macro was seeing the carriage return as the end of the line and I needed a
hex editor to see what was happening in the data.
Here's a better example. You may open a notepad document and see
something like this:
Tom
Dick
Harry
But the appearance of these is an illusion. After Tom and Dick there is
a CRLF (Carriage Return - Line Feed) and in the computer they are one long
string of characters. On the hard drive it looks like this:
01010100 01101111 01101101 00001101 00001010 01000100 01101001 01100011
01101011 00001101 00001010 01001000 01100001 01110010 01110010 01111001
There are spaces between the bytes that don't exist in reality.
In Hex it's:
54 6F 6D 0D 0A 44 69 63 6B 0D 0A 48 61 72 72 79
Now you can see the CRLF. It's actually two characters that
signify the end of a line 00001101 (0D) and 00001010 (0A). When Notepad
sees this string it will display the next bit of text on the next line
down and not display the CR or LF.
Back to my Outlook example by opening my data file with a text editor I
was able to see what was happening and I wrote a macro to make a
substitution in these cases and while running the ASCII File Process
command was able to replace the CRLF. Without doing this I would not have
been able to use that command effectively.
Another time this is helpful is with non-printing characters. For
instance the TAB which is often used a a delimiter in data files,
especially the clipboard in office applications.
Here we have the boys again and we copy them to the clipboard. and move
them to a variable and display it.
But are those spaces in between or what? No, they're tabs. And if we
wanted to parse (Break apart) this variable we would need to know that.
So I think you can see that using a hex editor to aide your macro
writing can be very valuable if you do any data manipulation.